#include "triangle.h"

Triangle::Triangle()
{
    this->vertex[0] = Point(0, 0);
    this->vertex[1] = Point(0, 0);
    this->vertex[2] = Point(0, 0);
}

Triangle::Triangle(const Point &a, const Point &b, const Point &c)
{
    this->vertex[0] = a;
    this->vertex[1] = b;
    this->vertex[2] = c;
}

Triangle::Triangle(int &x0, int &y0,
                   int &x1, int &y1,
                   int &x2, int &y2)
{
    this->vertex[0].setX(x0);
    this->vertex[0].setY(y0);
    this->vertex[1].setX(x1);
    this->vertex[1].setY(y1);
    this->vertex[2].setX(x2);
    this->vertex[2].setY(y2);
}

void Triangle::moveShape(const int &x, const int &y)
{
    this->vertex[0] += Point(x, y);
    this->vertex[1] += Point(x, y);
    this->vertex[2] += Point(x, y);
}

void Triangle::extensionShape(const double &scale)
{
    /*
     x0 y0     s 0
     x1 y1  x  0 s
     x2 y2

     where s - scale
     */
    this->vertex[0] = Point((this->vertex[0].getX() * scale),((this->vertex[0].getY() * scale)));
    this->vertex[1] = Point((this->vertex[0].getX() * scale),((this->vertex[0].getY() * scale)));
    this->vertex[2] = Point((this->vertex[0].getX() * scale),((this->vertex[0].getY() * scale)));
}

Point Triangle::getVertex(const int &index)
{
    return this->vertex[index];
}

std::string Triangle::saveData()
{
    std::string res = "t " ;
    res += std::to_string(this->vertex[0].getX());
    res += " ";
    res += std::to_string(this->vertex[0].getY());
    res += " ";
    res += std::to_string(this->vertex[1].getX());
    res += " ";
    res += std::to_string(this->vertex[1].getY());
    res += " ";
    res += std::to_string(this->vertex[2].getX());
    res += " ";
    res += std::to_string(this->vertex[2].getY());
    res += '\n';
    return res;
}

Triangle::~Triangle()
{

}
